import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
import path from 'path';
import purgecss from 'vite-plugin-purgecss-v2';


// https://vitejs.dev/config/
export default defineConfig({
  base: process.env.NODE_ENV === 'production' ? '/home-page' : '/',
  resolve: {
    alias: [
      {find: /^@\/(.*)$/, replacement: path.resolve(__dirname, './src/$1')}
    ]
  },
  build: {
    cssCodeSplit: true,
  },
  plugins: [
    svelte({
      onwarn: (waring, handle) => {
        if (/a11/i.test(waring.code)) return false;
        handle(waring);
      },
      compilerOptions: {
        hydratable: true
      }
    }),
    purgecss()
  ]
})
